package asteroids.entity.equipment;

import asteroids.engine.Utils;
import asteroids.entity.Icing;
import asteroids.entity.Ship;

public class ClassicExhaust extends Exhaust
{
    // add direction parameter for CompositeShips?
    public ClassicExhaust(Ship ship, Utils.PolarCoordinate relativePosition)
    {
        super(ship, relativePosition);
    }

    /**
     * make a guess as to where the exhaust port will be located.
     * 
     * @param ship
     */
    public ClassicExhaust(Ship ship)
    {
        super(ship, Utils.createPolarCoordinate(180, ship.getMaxRadius() * (2d / 3)));
    }

    /**
     * make cool exhaust effects
     */
    public void vroom()
    {
        for( int i = 0; i < 2; i++ )
        {
            Utils.CartesianCoordinate exhaust = getExhaustLocation();
            Icing j = new Icing(exhaust.getXComponent(), exhaust.getYComponent(),
                    (int) (.5 * Utils.FRAMES_PER_SECOND));
            j.setVelocity(Math.random() * (19.8 / Utils.FRAMES_PER_SECOND) - .15, Math.random()
                    * (19.8 / Utils.FRAMES_PER_SECOND) - .15);
            j.addVelocity(Utils.cartesianFromPolar(Utils.createPolarCoordinate(
                    ship.getRotation() + 180, 48.0 / Utils.FRAMES_PER_SECOND)));
            j.addVelocity(Utils.cartesianFromPolar(Utils.createPolarCoordinate(ship.getDirection(),
                    ship.getSpeed())));
            ship.addIcing(j);
        }
    }
}
